package com.bwie.home.backstage;

import com.bwie.home.common.config.CreateToken;
import com.bwie.home.common.util.JwtUtil;
import com.bwie.home.common.utils.OosSave;
import org.mybatis.spring.annotation.MapperScan;
import org.redisson.Redisson;
import org.redisson.config.Config;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.bootstrap.BootstrapConfiguration;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.context.annotation.Bean;

@SpringBootApplication
@EnableDiscoveryClient
@MapperScan("com.bwie.home.backstage.dao")
public class BackstageApplication {
    public static void main(String[] args) {
        SpringApplication.run(BackstageApplication.class);
    }
    @Bean
    public JwtUtil jwtUtil(){
        return new JwtUtil();
    }




    //OSS注入
    @Bean
    public OosSave oosSave(){
        return new OosSave();
    }

    //Redisson注入
    @Bean
    public Redisson redisson(){
        //单机模式=>useSingleServer
        Config config = new Config();
        config.useSingleServer().setAddress("redis://localhost:6379").setDatabase(0);
        return (Redisson) Redisson.create(config);
    }

    @Bean
    public CreateToken createToken(){
        return new CreateToken();
    }
}
